package com.manolo.framework.listener.dispatcher;

import java.util.ArrayList;
import java.util.List;

import com.manolo.framework.listener.DateListener;
import com.manolo.framework.listener.ReciveDateListener;
import com.manolo.framework.listener.event.DateEvent;

public class ReciveDateDispatcher {
	private static ReciveDateDispatcher instance;
	private List<ReciveDateListener> listeners;

	private ReciveDateDispatcher() {
		this.listeners = new ArrayList<ReciveDateListener>();
	}

	public synchronized static ReciveDateDispatcher getInstance() {
		if(ReciveDateDispatcher.instance == null) {
			ReciveDateDispatcher.instance = new ReciveDateDispatcher();
		}

		return ReciveDateDispatcher.instance;
	}

	public void addDateListener(ReciveDateListener listener) {
		this.listeners.add(listener);
	}

	public void removeDateListener(DateListener listener) {
		this.listeners.remove(listener);
	}

	public void dispatchDateEvent(DateEvent event) {
		for (ReciveDateListener listener : this.listeners) {
			listener.moveAction(event);
		}
	}
}
